<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>vue_demo1</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <h1>vue_demo1</h1>
    <hr/>
    <div id="app">
        {{ message }}
    </div>
    <div id="app-2">
        <span v-bind:title="message">
            鼠标悬停显示
        </span>
    </div>
    <div id="app-3">
        <p v-if="seen">
            现在你看到我了
        </p>
    </div>
    <div id="app-4">
        <ol>
            <li v-for="i in items">
                {{ i.text }}
            </li>
        </ol>
    </div>
    <div id="app-5">
        <p>{{ message }}</p>
        <button v-on:click="reverseMessage">逆转消息</button>
    </div>
    <div id="app-6">
        <p>{{ message }}</p>
        <input v-model="message">
    </div>
    <div id="app-7">
        <ol>
            <todo-item
                    v-for="item in list"
                    v-bind:todo="item"
                    v-bind:key="item.id">
            </todo-item>
        </ol>
    </div>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            message: 'Hello Vue!'
        }
    });
    var app2 = new Vue({
       el: '#app-2',
       data: {
           message: '页面加载于' + new Date().toLocaleString()
       }
    });
    var app3 = new Vue({
        el: '#app-3',
        data: {
            seen: true
        }
    });
    app3.seen = false;
    var app4 = new Vue({
       el: '#app-4',
       data: {
           items: [
               { text: "item1" },
               { text: "item2" },
               { text: "item3" }
           ]
       }
    });
    app4.items.push({text: "item4"});
    var app5 = new Vue({
        el: '#app-5',
        data: {
            message: 'Hello Vue.js!'
        },
        methods: {
            reverseMessage: function () {
                this.message = this.message.split('').reverse().join('')
            }
        }
    });
    var app6 = new Vue({
       el: '#app-6',
       data: {
           message: 'Hello Vue!'
       }
    });
    Vue.component('todo-item', {
        props:['todo'],
        template: '<li>{{ todo.text }}</li>'
    });
    var app7 = new Vue({
        el: '#app-7',
        data: {
            list: [
                { id: 0, text: 'line1' },
                { id: 1, text: 'line2' },
                { id: 2, text: 'line3' }
            ]
        }
    })
</script>
</body>
</html>